package cn.com.yusys.yusp.admin.web.rest;


import cn.com.yusys.yusp.admin.domain.AdminSmDataAuthTmpl;
import cn.com.yusys.yusp.admin.service.AdminSmDataAuthTmplService;
import cn.com.yusys.yusp.commons.service.CommonService;
import cn.com.yusys.yusp.commons.web.rest.CommonResource;
import cn.com.yusys.yusp.commons.web.rest.dto.ResultDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @项目名称: yusp-admin
 * @类名称: AdminSmDataAuthTmplResource
 * @类描述: 数据权限模板-数据过滤明细
 * @功能描述: 
 * @创建人: liaoxd@yusys.com.cn
 * @创建时间: 2017-12-27 18:02
 * @修改备注: 
 * @修改记录: 修改时间    修改人员    修改原因
 * -------------------------------------------------------------
 * @version 1.0.0
 * @Copyright (c) 2017宇信科技-版权所有
 */
@RestController
@RequestMapping("/api/adminsmdataauthtmpl")
public class AdminSmDataAuthTmplResource extends CommonResource<AdminSmDataAuthTmpl,String> {
	
	@Autowired
	private AdminSmDataAuthTmplService adminSmDataAuthTmplService;
	
	private final Logger log = LoggerFactory.getLogger(AdminSmDataAuthTmplResource.class);
	
	
	@Override
	protected CommonService getCommonService() {
		return this.adminSmDataAuthTmplService;
	}

	
	
	/**
	* @方法名称: deleteMult
	* @方法描述: 多个删除
	* @参数与返回说明: 
	* @算法描述: 
	*/
	@PostMapping("/deletes/{ids}")
	public ResultDto<Integer> deleteMult(@PathVariable String ids) {
		log.debug("REST request to delete Object : {}", ids);
		String[] id = ids.toString().split(",");
		ResultDto<Integer> resultDto = new ResultDto<>();
		int i;
		for(i=0;i<id.length;i++) {
			this.adminSmDataAuthTmplService.deletes(id[i]);
		}
		int result =i;
		if(result >=1){
			resultDto.setMessage("删除数据权限模板 id:"+ids);
		}
		resultDto.setData(result);
		return resultDto;
		
	}
	
	/**
	* @方法名称: updateSelective
	* @方法描述: 修改
	* @参数与返回说明: 
	* @算法描述: 
	*/
	@PostMapping("/updates")
	public ResultDto<Integer>  updateSelective(@RequestBody AdminSmDataAuthTmpl t) throws Exception {
		log.debug("REST request to update Object : {}", t);

		int result = getCommonService().updateSelective(t);
		ResultDto<Integer> resultDto = new ResultDto<>();
		if(result >= 1){
			resultDto.setMessage("数据权限模板修改");
		}
		resultDto.setData(result);
		return resultDto;
	}
	
	
	
		
}
